﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SW.Lite.BLL;
using SW.Lite.Core.Authority;
using SW.Lite.Model;

namespace SW.Lite.WebSite.Areas.Master.Controllers
{
    public class ArticleController : BaseController
    {
        [Menu(MenuCode = "ArticleManage")]
        public ActionResult Index()
        {
            var list = Column.All().ToList();
            list.Add(new ColumnModel
            {
                Id = 0,
                ParentID = 0,
                Title = "栏目列表",
                Code = "",
                Sort = -1
            });

            list.Sort(new ColumnComparer());
            var result = list.Select(n => new
            {
                id = n.Id.ToString(),
                pid = n.ParentID == 0 ? n.ParentID.ToString() : Guid.Empty.ToString(),
                name = n.Title,
                n.Code,
                open = true
            });
            ViewBag.Tree = Newtonsoft.Json.JsonConvert.SerializeObject(result);
            return View();
        }
    }
}
